package com.goods.business.converter;

import com.goods.common.model.business.Product;
import com.goods.common.model.business.Supplier;
import com.goods.common.vo.business.ProductVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**********************
 *
 *@Author 闫星忠
 *@Time 2021/12/16  10:25
 *
 */
public class ProductConverter {

    public static ProductVO converterToProductVO(Product product){
        ProductVO productVO = new ProductVO();
        BeanUtils.copyProperties(product,productVO);
        return productVO;
    }


    public static List<ProductVO> converterToProductVOList(List<Product> products){
        List<ProductVO> productVOS = new ArrayList<>();
        if (!CollectionUtils.isEmpty(products)){
            for (Product product : products){
                ProductVO productVO = new ProductVO();
                BeanUtils.copyProperties(product,productVO);
                productVOS.add(productVO);
            }
        }

        return productVOS;
    }
}
